<template>
	<view class="mine-balance-index rel" v-if="isLoad">
		<view class="count-info flex-center flex-column c-base" :style="{background:primaryColor}">
			<view class="f-caption">{{mineInfo.is_user?'我的余额(元)':'可提余额(元)'}}</view>
			<view class="price mt-sm">{{mineInfo.is_user?mineInfo.balance:mineInfo.wallet_cash}}</view>
			<view class="flex-center btn-list f-paragraph mt-lg pt-lg">
				<view @tap.stop="$util.goUrl({url:`/mine/pages/balance/list`})"
					class="item-child flex-center fill-base c-title mr-lg radius">充值</view>
				<view @tap.stop="$util.goUrl({url:`/mine/pages/cash-out?type=business`})"
					class="item-child flex-center c-base radius" v-if="!mineInfo.is_user">提现</view>
			</view>
		</view>
		<view class="money-count fill-base flex-center pt-lg pb-lg" v-if="!mineInfo.is_user">
			<view class="item-child flex-center flex-column b-1px-r">
				<view class="flex-y-baseline f-lg-title">{{mineInfo.balance}}</view>
				<view class="f-caption c-caption">总金额(元)</view>
			</view>
			<view class="item-child flex-center flex-column">
				<view class="flex-y-baseline f-lg-title">{{mineInfo.frozen_cash}}</view>
				<view class="f-caption c-caption">不可用余额(元)</view>
			</view>
		</view>
		<view @tap.stop="$util.goUrl({url:`/mine/pages/balance/record`})" class="flex-between mt-md pd-lg fill-base">
			<view class="f-title c-title">交易记录</view>
			<i class="iconfont icon-right"></i>
		</view>
		<view class="space-footer"></view>
	</view>
</template>

<script>
	import {
		mapState,
		mapActions
	} from "vuex"
	import tabbar from "@/components/tabbar.vue"
	export default {
		components: {
			tabbar
		},
		data() {
			return {
				detail: {},
				isLoad: false
			}
		},
		computed: mapState({
			primaryColor: state => state.config.configInfo.primaryColor,
			subColor: state => state.config.configInfo.subColor,
			configInfo: state => state.config.configInfo,
			commonOptions: state => state.user.commonOptions,
			userInfo: state => state.user.userInfo,
			mineInfo: state => state.user.mineInfo,
		}),
		onLoad() {
			this.$util.setNavigationBarColor({
				color: '#ffffff',
				bg: '#39b54a'
			});
			this.initIndex()
		},
		onUnload() {
			this.$util.back()
		},
		onPullDownRefresh() {
			// #ifndef APP-PLUS
			uni.showNavigationBarLoading()
			// #endif
			this.initRefresh()
			uni.stopPullDownRefresh()
		},
		methods: {
			...mapActions(['getMineInfo']),
			async initIndex() {
				await this.getMineInfo()
				this.$util.hideAll()
				this.isLoad = true
			},
			initRefresh() {
				this.initIndex()
			}
		}
	}
</script>


<style lang="scss">
	.mine-balance-index {

		.count-info {
			height: 450rpx;

			.price {
				font-size: 70rpx;
			}

			.btn-list {
				.item-child {
					width: 240rpx;
					height: 64rpx;
					border: 1rpx solid #fff;
					transform: rotateZ(360deg);
				}
			}
		}

		.money-count {
			.item-child {
				width: 50%;
			}
		}
	}
</style>
